! function(w){//加载更多插件
	"use strict";
	if(w._hcinits==undefined){console.log('_layer_admin.js load _hcinits fail');}
	var _h=w._hcinits;
	var _layer_admin={ 
		'loading':function(){
			$('#layer_loading_admin_status').val(0);
			var index=layer.msg('加载中...',{icon:6,time:5000},function(){
					var status=$('#layer_loading_admin_status').val();
					if(status==0){
						 _layer_admin.errorMsg('加载失败,加载超过5秒了...');
					}
			}); 
			$('#layer_loading_admin').val(index);
		},
		'noloading':function(index){
			 parent.layer.close(index);
		},
		'confirm':function(msg,btn1func,btn2func){
			layer.confirm(msg, {
				btn: ["确认","取消"] //按钮
			},function(index){
				if(btn1func!=undefined){
					btn1func(index);
				}else{
					layer.close(index);
				}
			}, function(index){
				if(btn2func!=undefined){
					btn2func(index);
				}
			});
		},
		'tips':function(msg,classid,type){
			if(type==undefined){
				type='#0e7066';
			}else{
				type='#ff6737';
			}
			layer.tips(msg,classid,{ 
			  tips: [1,type],
			  time: 2000
			});
		},
		'successMsg':function(msg,returnback){//成功提示
			layer.msg(msg,{icon:1,time:1000},function(){
				if(returnback==1){//刷新当前页面;
					window.location.reload();
					return false;
				}else if(returnback==2){//关闭当前弹窗，不刷新父页面
					_layer_admin.parentclose();
					return false;
				}else if(returnback==3){//关闭当前弹窗，并刷新父页面
					_layer_admin.parentclose();
					window.parent.location.reload();
					return false;
				}
				if(returnback != undefined){returnback();}
				//if(returnback != undefined){eval(returnback)();}
			});  
		},
		'errorMsg':function(msg,returnback){//提示失败
			layer.msg(msg,{icon:2,time:3500},function(){
				if(returnback != undefined){returnback();}
			});  
		},
		'open':function(title,url,w,h){//打开窗口
			if (title == undefined || title == ''){_layer_admin.errorMsg('标题不能为空');return false;};
			if (url == undefined || url == '') { _layer_admin.errorMsg('url地址不存在');return false;}
			if (w == undefined) {w="60%";}
			if (h == undefined) {h="90%";}
			var count=arguments.length;
			var success_layer=0;
			var cancel_layer=0;
			var end_layer=0;
			var parentdefault=0;
			if(count>4){
				for(i=4;i<count;i++){
					if(arguments[i].indexOf('success')!=-1){
						success_layer=arguments[i];
					}else if(arguments[i].indexOf('cancel')!=-1){
						cancel_layer=arguments[i];
					}else if(arguments[i].indexOf('end')!=-1){
						end_layer=arguments[i];
					}else if(arguments[i].indexOf('parent')!=-1){
						parentdefault=parentdefault+1;
					}
				}
			}
			var parentstr='';
			if(parentdefault!=0){
				for(i=0;i<parentdefault;i++){
					parentstr+="parent.";
				}
				parentstr=parentstr.substr(0,parentstr.length-1);
			}
			if(parentstr!=''){
				layer=eval(parentstr).layer;
			}
			var cur_index=layer.open({
				title: title,
				type: 2,
				area: [w,h],
				shadeClose: true,//是否点击遮罩关闭
				shade:0.3,//遮罩即弹层外区域。默认是0.3透明度的黑色背景（'#000'）。如果你想定义别的颜色，可以shade: [0.8, '#393D49']；如果你不想显示遮罩，可以shade: 0
				content: url,
				offset: 'auto',
				maxmin:true,
				moveOut:true,//是否允许拖拽到窗口外
				success: function(layero, index){//层弹出后的成功回调方法
					if(success_layer==0){
						return true;
					}else{
						var body = layer.getChildFrame('body', index);//获取当前弹窗层body
						eval(success_layer)(body,index,layero);
					}
				},
				cancel: function(index,layero){//右上角关闭按钮触发的回调
					if(cancel_layer==0){
						return true;
					}else{
						var body = layer.getChildFrame('body', index);//获取当前弹窗层body
						// var canclose=body.find('.class').val();//查询弹窗层的class为class的值。
						eval(cancel_layer)(body,index,layero);//false； 不能关闭弹窗，可以关闭弹窗
					}
				},
				end:function(){//层销毁后触发的回调
					if(end_layer==0){
						return true;
					}else{
						 eval(end_layer)();
					}
				}     
			});
			return cur_index;
		},
		'parentclose':function(returnback,arr){//当前iframe 窗口 关闭后，父级回调函数 returnback,回调参数arr;
			var index = parent.layer.getFrameIndex(window.name);
			parent.layer.close(index);
			if(returnback != undefined && arr != undefined){
				window.parent.eval(returnback)(arr);
			}else if(returnback != undefined){
				window.parent.eval(returnback)();
			}
		},
		'curclose':function(indexclose){//当前页面关闭
			if(indexclose!=undefined){
				layer.close(indexclose);
			}else{
				layer.closeAll();
			}
		},
		'show_photo':function(clickclass,objs,anim,closeBtn){//图片预览
			//clickclass点击样式 objs//当前默认预览图片
			if(!anim){anim=5;}
			if(!closeBtn){closeBtn=1;}
			var obj=$(clickclass);
			var count=obj.length;
			var showarr=[];
			var cur_src=objs.attr('src');
			var cur_id;
			for(i=0;i<count;i++){
				var alt=obj.eq(i).attr('alt');
				var pid=obj.eq(i).attr('pid');
				var src=obj.eq(i).attr('src');
				var thumb=obj.eq(i).attr('thumb');
				if(src==cur_src){
					cur_id=i;
				}
				showarr[i]={
					'alt':alt,
					'pid':pid,
					'src':src,
					'thumb':thumb,
				};
			}
			var showjson={"title": "图片预览","id":count,"start":cur_id,"data":showarr};
			// //图片点击放大
			layer.photos({
				photos:showjson,
				anim: anim,
				closeBtn:closeBtn
			});
		},
	}
	_h._layer_admin=_layer_admin;
}(window)